{% extends 'adminuser/base_admin.html' %}

{% block admin_title %}系统设置{% endblock %}

{% block admin_content %}
<div class="card">
    <div class="card-header bg-primary text-white">
        <h5 class="mb-0">系统配置</h5>
    </div>
    <div class="card-body">
        <form method="post">
            {% csrf_token %}
            
            <div class="mb-3">
                <label for="site_name" class="form-label">网站名称</label>
                <input type="text" class="form-control" id="site_name" name="site_name" value="{{ settings.value.site_name }}" required>
                <div class="form-text">设置网站的显示名称</div>
            </div>
            
            <div class="mb-3">
                <label for="site_description" class="form-label">网站描述</label>
                <textarea class="form-control" id="site_description" name="site_description" rows="3">{{ settings.value.site_description }}</textarea>
                <div class="form-text">简要描述网站的功能和目的</div>
            </div>
            
            <div class="mb-3">
                <div class="form-check form-switch">
                    <input class="form-check-input" type="checkbox" id="allow_registration" name="allow_registration" {% if settings.value.allow_registration %}checked{% endif %}>
                    <label class="form-check-label" for="allow_registration">允许新用户注册</label>
                </div>
                <div class="form-text">关闭此选项将阻止新用户注册</div>
            </div>
            
            <div class="mb-3">
                <div class="form-check form-switch">
                    <input class="form-check-input" type="checkbox" id="allow_story_creation" name="allow_story_creation" {% if settings.value.allow_story_creation %}checked{% endif %}>
                    <label class="form-check-label" for="allow_story_creation">允许创建新故事</label>
                </div>
                <div class="form-text">关闭此选项将阻止普通用户创建新故事</div>
            </div>
            
            <div class="mb-3">
                <div class="form-check form-switch">
                    <input class="form-check-input" type="checkbox" id="maintenance_mode" name="maintenance_mode" {% if settings.value.maintenance_mode %}checked{% endif %}>
                    <label class="form-check-label" for="maintenance_mode">维护模式</label>
                </div>
                <div class="form-text text-danger">开启维护模式将限制普通用户访问网站的大部分功能</div>
            </div>
            
            <button type="submit" class="btn btn-primary">
                <i class="bi bi-save"></i> 保存设置
            </button>
        </form>
    </div>
</div>

<div class="card mt-4">
    <div class="card-header bg-info text-white">
        <h5 class="mb-0">高级操作</h5>
    </div>
    <div class="card-body">
        <div class="row">
            <div class="col-md-4">
                <div class="card mb-3">
                    <div class="card-body text-center">
                        <h5 class="card-title">清理临时文件</h5>
                        <p class="card-text">删除未使用的临时文件和缓存</p>
                        <button type="button" class="btn btn-outline-primary" data-bs-toggle="modal" data-bs-target="#cleanTempModal">
                            <i class="bi bi-trash"></i> 执行清理
                        </button>
                    </div>
                </div>
            </div>
            
            <div class="col-md-4">
                <div class="card mb-3">
                    <div class="card-body text-center">
                        <h5 class="card-title">备份数据库</h5>
                        <p class="card-text">创建数据库的完整备份</p>
                        <button type="button" class="btn btn-outline-primary" data-bs-toggle="modal" data-bs-target="#backupDBModal">
                            <i class="bi bi-download"></i> 开始备份
                        </button>
                    </div>
                </div>
            </div>
            
            <div class="col-md-4">
                <div class="card mb-3">
                    <div class="card-body text-center">
                        <h5 class="card-title">系统更新检查</h5>
                        <p class="card-text">检查系统是否有可用更新</p>
                        <button type="button" class="btn btn-outline-primary" data-bs-toggle="modal" data-bs-target="#checkUpdateModal">
                            <i class="bi bi-arrow-repeat"></i> 检查更新
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 模态框 -->
<div class="modal fade" id="cleanTempModal" tabindex="-1" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">确认清理临时文件</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
                <p>您确定要清理临时文件吗？这将删除系统中的缓存和未使用的临时文件。</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary">确认清理</button>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="backupDBModal" tabindex="-1" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">备份数据库</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
                <p>您确定要备份数据库吗？这将创建一个包含所有数据的备份文件。</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary">开始备份</button>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="checkUpdateModal" tabindex="-1" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">检查系统更新</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
                <p>您确定要检查系统更新吗？</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary">开始检查</button>
            </div>
        </div>
    </div>
</div>
{% endblock %} 